package com.wzm.testcase;

import com.wzm.api.WarehouseInAPI;
import com.wzm.pojo.Rsp;
import com.wzm.utils.Utils;
import org.apache.commons.lang3.RandomStringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
import org.testng.annotations.Test;


public class TestWarehouseIn {

    WarehouseInAPI inAPI = new WarehouseInAPI();
    Logger logger = LoggerFactory.getLogger(this.getClass().getName());
    @Test(description = "添加入库单")
    public void testAdd(){
        Rsp request = inAPI.addWarehouseIn(RandomStringUtils.randomAlphabetic(16),"test","test","1","","");
        inAPI.editWarehouseIn("","","","","","");
        logger.info(request.getMessage());
//        Assert.assertEquals(Utils.extractToStr(request,"message"),"添加成功！");
    }

    @Test(description = "添加入库单重复")
    public void testAddNumberRepeat(){
        Rsp request2 = inAPI.addWarehouseIn("1212","test","test","1","","");
        Assert.assertEquals(Utils.extractToStr(request2.getMessage(),"message"),"单号重复！");
    }

    @Test(description = "添加入库单未选择库房")
    public void testAddNoWarehouse(){
        Rsp request2 = inAPI.addWarehouseIn(RandomStringUtils.randomAlphabetic(16),"test","test","1","","");
        Assert.assertEquals(Utils.extractToStr(request2.getMessage(),"message"),"单号重复！");
    }

    @Test
    public void testQuery(){

        String p = inAPI.queryList();
        logger.info(p);

    }

    @Test
    public void tesueryWarehouseIn(){
        Rsp r = inAPI.queryWarehouseIn();
        logger.info(r.getResult().getRecords().get(1).toString());
        logger.info(String.valueOf(r.getSuccess()));
    }

}
